// pages/webView/webView.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    wx_url: '',
    shareTitle: '',
    shareImg: '',
    baseUrl: app.baseUrl,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var wx_url = options.wx_url;
    console.log(wx_url);
    if (wx_url == ''||wx_url==undefined) {
      app.showTip('抱歉,未获取到跳转的公众号链接哦');
      setTimeout(function() {
        wx.navigateBack({
          delta: 1
        });
      }, 2000);
      return;
    } else {
      this.setData({
        wx_url: wx_url
      });
    }
    //this.checkApi();
  },

  /*checkApi() {
    var that=this;
    wx.request({
      url: that.data.baseUrl + 'api/getApiData.php',
      method: 'POST',
      data: {
        'apiUrl': '/openapi/maintOrder/v1/evaluate',
        'data': JSON.stringify({"userId":"1770732204927873026","id":"1788164854107418625","content":"测试","labelArr":["响应快速"],"comfLevel":2})
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        
        if (res.data.status == 1) {
     
        } else {
          
        }
      },
      fail: function() {

      }
    });
  },*/

  //获取微信分享信息
  getShareInfo() {
    var that = this;
    wx.request({
      url: that.data.baseUrl + 'getShareInfo.php',
      method: 'POST',
      data: {},
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        that.setData({
          shareTitle: res.data.shareTitle,
          shareImg: res.data.shareImg
        });
      },
      fail: function (res) {}
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },



  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var that = this;
    return {
      title: that.data.shareTitle,
      path: '/pages/webView/webView?wx_url=' + that.data.wx_url,
      imageUrl: that.data.shareImg,
      success: function (res) {

      },
      fail: function (res) {

      }
    }
  }
})